home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / MoreFiles 1.3.1 / FileCopy.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-16  |  5.1 KB  |  133 lines  |  [TEXT/MMCC]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    FileCopy: A robust, general purpose file copy routine.
  5. **
  6. **    by Jim Luther, Apple Developer Technical Support
  7. **
  8. **    File:        FileCopy.h
  9. **
  10. **    Copyright © 1992-1995 Apple Computer, Inc.
  11. **    All rights reserved.
  12. **
  13. **    You may incorporate this sample code into your applications without
  14. **    restriction, though the sample code has been provided "AS IS" and the
  15. **    responsibility for its operation is 100% yours.  However, what you are
  16. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  17. **    after having made changes. If you're going to re-distribute the source,
  18. **    we require that you make it clear in the source that the code was
  19. **    descended from Apple Sample Code, but that you've made changes.
  20. */
  21.  
  22. #ifndef __FILECOPY__
  23. #define __FILECOPY__
  24.  
  25. #include <Types.h>
  26. #include <Files.h>
  27.  
  28. /*****************************************************************************/
  29.  
  30. pascal    OSErr    FileCopy(short srcVRefNum,
  31.                          long srcDirID,
  32.                          ConstStr255Param srcName,
  33.                          short dstVRefNum,
  34.                          long dstDirID,
  35.                          StringPtr dstPathname,
  36.                          StringPtr copyName,
  37.                          void *copyBufferPtr,
  38.                          long copyBufferSize,
  39.                          Boolean preflight);
  40. /*    ¶ Duplicate a file and optionally rename it.
  41.     The FileCopy function duplicates a file and optionally renames it.
  42.     Since the PBHCopyFile routine is only available on some
  43.     AFP server volumes under specific conditions, this routine
  44.     either uses PBHCopyFile, or does all of the work PBHCopyFile
  45.     does.  The srcVRefNum, srcDirID and srcName are used to
  46.     determine the location of the file to copy.  The dstVRefNum
  47.     dstDirID and dstPathname are used to determine the location of
  48.     the destination directory.  If copyName <> NIL, then it points
  49.     to the name of the new file.  If copyBufferPtr <> NIL, it
  50.     points to a buffer of copyBufferSize that is used to copy
  51.     the file's data.  The larger the supplied buffer, the
  52.     faster the copy.  If copyBufferPtr = NIL, then this routine
  53.     allocates a buffer in the application heap. If you pass a
  54.     copy buffer to this routine, make its size a multiple of 512
  55.     ($200) bytes for optimum performance.
  56.     
  57.     srcVRefNum        input:    Source volume specification.
  58.     srcDirID        input:    Source directory ID.
  59.     srcName            input:    Source file name.
  60.     dstVRefNum        input:    Destination volume specification.
  61.     dstDirID        input:    Destination directory ID.
  62.     dstPathname        input:    Pointer to destination directory name, or
  63.                             nil when dstDirID specifies a directory.
  64.     copyName        input:    Points to the new file name if the file is
  65.                             to be renamed or nil if the file isn't to
  66.                             be renamed.
  67.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  68.                             is used the i/o buffer for the copy or
  69.                             nil if you want FileCopy to allocate its
  70.                             own buffer in the application heap.
  71.     copyBufferSize    input:    The size of the buffer pointed to
  72.                             by copyBufferPtr.
  73.     preflight        input:    If true, FileCopy makes sure there are enough
  74.                             allocation blocks on the destination volume to
  75.                             hold both the data and resource forks before
  76.                             starting the copy.
  77.  
  78.     __________
  79.     
  80.     Also see:    FSpFileCopy, DirectoryCopy, FSpDirectoryCopy
  81. */
  82.  
  83. /*****************************************************************************/
  84.  
  85. pascal    OSErr    FSpFileCopy(const FSSpec *srcSpec,
  86.                             const FSSpec *dstSpec,
  87.                             StringPtr copyName,
  88.                             void *copyBufferPtr,
  89.                             long copyBufferSize,
  90.                             Boolean preflight);
  91. /*    ¶ Duplicate a file and optionally rename it.
  92.     The FSpFileCopy function duplicates a file and optionally renames it.
  93.     Since the PBHCopyFile routine is only available on some
  94.     AFP server volumes under specific conditions, this routine
  95.     either uses PBHCopyFile, or does all of the work PBHCopyFile
  96.     does.  The srcSpec is used to
  97.     determine the location of the file to copy.  The dstSpec is
  98.     used to determine the location of the
  99.     destination directory.  If copyName <> NIL, then it points
  100.     to the name of the new file.  If copyBufferPtr <> NIL, it
  101.     points to a buffer of copyBufferSize that is used to copy
  102.     the file's data.  The larger the supplied buffer, the
  103.     faster the copy.  If copyBufferPtr = NIL, then this routine
  104.     allocates a buffer in the application heap. If you pass a
  105.     copy buffer to this routine, make its size a multiple of 512
  106.     ($200) bytes for optimum performance.
  107.     
  108.     srcSpec            input:    An FSSpec record specifying the source file.
  109.     dstSpec            input:    An FSSpec record specifying the destination
  110.                             directory.
  111.     copyName        input:    Points to the new file name if the file is
  112.                             to be renamed or nil if the file isn't to
  113.                             be renamed.
  114.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  115.                             is used the i/o buffer for the copy or
  116.                             nil if you want FileCopy to allocate its
  117.                             own buffer in the application heap.
  118.     copyBufferSize    input:    The size of the buffer pointed to
  119.                             by copyBufferPtr.
  120.     preflight        input:    If true, FSpFileCopy makes sure there are
  121.                             enough allocation blocks on the destination
  122.                             volume to hold both the data and resource forks
  123.                             before starting the copy.
  124.  
  125.     __________
  126.     
  127.     Also see:    FileCopy, DirectoryCopy, FSpDirectoryCopy
  128. */
  129.  
  130. /*****************************************************************************/
  131.  
  132. #endif    /* __FILECOPY__ */
  133.